<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2025/5/4
  Time: 16:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.project.DB_Flight" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%
    // 获取表单提交的参数
    String fid = request.getParameter("fid");
    String starttime = request.getParameter("starttimeYear") + "-" +
            request.getParameter("starttimeMonth") + "-" +
            request.getParameter("starttimeDay") + " " +
            request.getParameter("starttimeHour") + ":" +
            request.getParameter("starttimeMinute") + ":" +
            request.getParameter("starttimeSecond");
    String endtime = request.getParameter("endtimeYear") + "-" +
            request.getParameter("endtimeMonth") + "-" +
            request.getParameter("endtimeDay") + " " +
            request.getParameter("endtimeHour") + ":" +
            request.getParameter("endtimeMinute") + ":" +
            request.getParameter("endtimeSecond");
    String takeoffstation = request.getParameter("takeoffstation");
    String arrivalstation = request.getParameter("arrivalstation");
    String boardingtime = request.getParameter("boardingtimeYear") + "-" +
            request.getParameter("boardingtimeMonth") + "-" +
            request.getParameter("boardingtimeDay") + " " +
            request.getParameter("boardingtimeHour") + ":" +
            request.getParameter("boardingtimeMinute") + ":" +
            request.getParameter("boardingtimeSecond");

    // 构建更新数据的List
    List<String> updateInput = new ArrayList<>();
    updateInput.add(fid);
    updateInput.add(starttime);
    updateInput.add(endtime);
    updateInput.add(takeoffstation);
    updateInput.add(arrivalstation);
    updateInput.add(boardingtime);

    // 调用DB_Flight的update方法进行更新
    DB_Flight dbFlight = new DB_Flight();
    boolean updateResult = dbFlight.update(updateInput);

    if (updateResult) {
        // 更新成功，重定向到航班列表页面
        response.sendRedirect("index.jsp");
    } else {
        // 更新失败，显示错误信息
        out.println("更新航班失败");
    }
%>